import { Action } from 'redux';
import { UserActions } from '../actions';
import { createSelector } from 'reselect';

interface User {

}

export interface UsersState {
  currentUser: User;
};

const initialState: UsersState = {
  currentUser: "start"
};

export const UsersReducer =
  function(state: UsersState = initialState, action: Action): UsersState {
  switch (action.type) {
    case UserActions.ADD_THREAD:
      return {
        currentUser: "action"
      };
    default:
      return state;
  }
};

// 数据选择器
export const getStateAction = (state): UsersState => state.users;
export const getAction = createSelector(
  getStateAction,
  ( state: UsersState ) => state.currentUser );